package cn.zt.controller;

import cn.zt.common.Result;
import cn.zt.domain.Bankcard;
import cn.zt.domain.vo.RechargeVo;
import cn.zt.domain.vo.TransferVo;
import cn.zt.service.BalanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zt.domain.Balance;

import javax.annotation.Resource;

@RestController
@RequestMapping("/balance")
public class BalanceController {
    @Autowired
    private BalanceService balanceService;


    //转账
    @GetMapping("/transfer")
    public Result transfer(TransferVo transferVo) {
        Result result = balanceService.transfer(transferVo);
        return result;
    }

    //根据账号查余额
    @GetMapping("/selectBalanceByBankCard")
    public Result selectBalanceByBankCard(String bankCard) {
        Result result = balanceService.selectBalanceByBankCard(bankCard);
        return result;
    }
    //添加余额
    @PostMapping("addbalance")
    public int addBalance(@RequestBody Balance balance) {
        return balanceService.addBalance(balance);
    }

    //查询余额
    @GetMapping("/selectbalance")
    public Bankcard selectBalance(String bankCard) {
        Bankcard bankcard = balanceService.selectbalance(bankCard);
        return bankcard;
    }

    //充值
    @PostMapping("/addmoney")
    public Result addMoney(RechargeVo rechargeVo) {
        return balanceService.addMoney(rechargeVo);
    }

    //    提现
    @PostMapping("/withdrawals")
    public Result withdrawals(RechargeVo rechargeVo) {
        return balanceService.withdrawals(rechargeVo);
    }


    //信用卡转入主卡
    @PostMapping("CreditToBank")
    public Result CreditToBank(@RequestBody Balance balance){
        return balanceService.CreditToBank(balance);
    }

    //从主卡进行信用卡还款
    @PostMapping("BankToCredit")
    public Result BankToCredit(@RequestBody Balance balance){
        return balanceService.BankToCredit(balance);
    }


}




